import type { FormOptions } from '../types/types';

export interface Model {
  [key: string]: any;
}

export const toModel = (options: FormOptions[]) => {
  const model: Model = {};
  options.forEach((item) => {
    model[item.prop] = item.value;
  });
  return model;
};

export const thorwPropRepeat = (options: FormOptions[]) => {
  const map = new Map<string, boolean>();
  options.forEach((item) => {
    if (map.has(item.prop)) {
      throw new Error('prop重复定义');
    }
    map.set(item.prop, true);
  });
  return true;
};
